var form = layui.form;
var $ = layui.$;
var layer = layui.layer;
var element = layui.element;
var laytpl = layui.laytpl;
var laypage = layui.laypage;
var upload = layui.upload;
var laydate = layui.laydate
function formSubmit(url, submit, dataType, func) {
	form.on(submit, function(data) {
		ajax(url, data.field, dataType, func);
	})
}

function ajax(url, field, dataType, func) {
	$.ajax({
		url : base.app + url,
		type : "post",
		data : field,
		dataType : dataType,
		success : func
	})
}
function getlaytpl(sel, data) {
	return laytpl($(sel).html()).render(data);
}

function openlayer(url, end) {
	layer.open({
		type : 2,
		area : [ '650px', '400px' ],
		fixed : false,
		maxmin : true,
		content : base.app + url,
		end : end
	})
}

function openlayerPro(url, end) {
	layer.open({
		type : 2,
		area : [ '650px', '500px' ],
		fixed : false,
		maxmin : true,
		content : base.app + url,
		end : end
	})
}

function renderDate(id){
	laydate.render({
		elem:"#"+id,
		type:"date",
		value:new Date()//在日期框中显示系统当前时间
		
	})
}

function closeThis() {
	var index = parent.layer.getFrameIndex(window.name);
	parent.layer.close(index);
}

function openConfirm(func, title) {
	layer.confirm(title ? title : "确定进行该操作？", {
		icon : 2,
		title : "提示"
	}, func)
}
//
function setPageInfo(elem, count, curr, limit,jump) {
	//分页模块的渲染
	laypage.render({
				elem : elem,
				count : count,// 多少条记录
				curr : curr,// 起始页是第一页
				limit : limit,// 每页显示十条记录
				limits : [ 10, 20, 30, 40, 50 ],
				layout : [ 'count', 'prev', 'page', 'next', 'limit', 'refresh',
						'skip' ],
				jump : jump
			});
			//当分页被切换时，触发jump，该方法有两个参数，分别是
			//obj=当前分页所有选项的值
			//first=是否是首次，一般用于初始加载时的判断
}

function renderUpload(id,url,data,func){
	upload.render({
		elem:"#"+id,
		url:base.app+url,
		data:data,
		done:func
	})
}

